package gyn.fgsl.fragments;

import gyn.fgsl.R;
import gyn.fgsl.adapters.ExpandableListViewCalendario;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnGroupCollapseListener;

import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;

public class CalendarioFragment extends SherlockFragment{

	private ExpandableListView listView;
	String[] horarios = {"08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00",
							"15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00"};
	String[][] eventos = {	{"Abertura", "Cochinha com catupiry"}, //08:00
							{"Stallman", "Arroz com ovo1", "qiwhqiw"}, //09:00
							{"Stallman", "Arroz com ovo2"}, //10:00
							{"Stallman", "Arroz com ovo3"}, //11:00
							{}, //12:00
							{}, //13:00
							{"Stallman", "Arroz com ovo6"}, //14:00
							{"Stallman", "Arroz com ovo7"}, //15:00
							{"Stallman", "Arroz com ovo8"}, //16:00
							{"Stallman", "Arroz com ovo9"}, //17:00
							{"Stallman", "Arroz com ovo0"}, //18:00
							{"Stallman", "Arroz com ovo09"}, //19:00
							{"Stallman", "Arroz com ovo96"}, //20:00
							{"Stallman", "Arroz com ovo12"}, //21:00
							};
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);
	}
	
	@Override
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
		super.onCreateOptionsMenu(menu, inflater);
		inflater.inflate(R.menu.calendario_menu, menu);
	}
							
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.calendario_fragment, container, false);
	}
	
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		listView = (ExpandableListView) view.findViewById(R.id.listview_horarios);
		ExpandableListViewCalendario adapter = new ExpandableListViewCalendario(horarios, eventos, getActivity());
		listView.setAdapter(adapter);
		for(int i = 0; i < horarios.length; i++)
			listView.expandGroup(i);
		listView.setOnGroupCollapseListener(new OnGroupCollapseListener() {
			
			@Override
			public void onGroupCollapse(int groupPosition) {
				listView.expandGroup(groupPosition);
			}
		});
		listView.setIndicatorBounds(50, 50);
	}
	
}
